﻿Imports System.Windows.Data

''' <summary>
''' 
''' </summary>
''' <remarks></remarks>
Public Class ArrayStringConverter
    Implements IValueConverter


    Private Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        Try
            If value Is Nothing Then Return ""
            Dim datas As IEnumerable = TryCast(value, IEnumerable)
            If datas Is Nothing Then Return value.ToString()
            Dim q = datas.Cast(Of Object).Where(Function(obj) obj IsNot Nothing).Select(Function(obj) "'" & obj.ToString() & "'").ToArray()

            Return String.Join(";", q)
        Catch ex As Exception
            Return "Erreur='" & ex.Message & "'"
        End Try
    End Function

    Private Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function
End Class